package sctu.edu.java.year2016.team07.shihaocheng.day20160521.Chapter5_2;

/**
 * Created by admin on 2016/5/22.
 *创建数组arr[],并输出最大值
 */
import java.util.Scanner;
public class chapter5_2 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n,i;
        System.out.print("请输入数组a[]的元素个数:");

        n=in.nextInt();// 数组的输入？

        int[] a=new int[n];

        System.out.println("请输入数组");

        for(i=0;i<n;i++){
            a[i]=in.nextInt();
        }

        for (int b=1;b<=a.length-1;b++) {
        n=a[b-1]>a[b]?a[b-1]:a[b];}


        System.out.println("the max is "+n);
    }
}
